package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbNetAttack;
import com.ruoyi.system.service.ITbNetAttackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网络攻击表Controller
 * 
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/attack")
public class TbNetAttackController extends BaseController
{
    @Autowired
    private ITbNetAttackService tbNetAttackService;

    /**
     * 查询网络攻击表列表
     */
    @PreAuthorize("@ss.hasPermi('system:attack:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbNetAttack tbNetAttack)
    {
        startPage();
        List<TbNetAttack> list = tbNetAttackService.selectTbNetAttackList(tbNetAttack);
        return getDataTable(list);
    }

    /**
     * 导出网络攻击表列表
     */
    @PreAuthorize("@ss.hasPermi('system:attack:export')")
    @Log(title = "网络攻击表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbNetAttack tbNetAttack)
    {
        List<TbNetAttack> list = tbNetAttackService.selectTbNetAttackList(tbNetAttack);
        ExcelUtil<TbNetAttack> util = new ExcelUtil<TbNetAttack>(TbNetAttack.class);
        util.exportExcel(response, list, "网络攻击表数据");
    }

    /**
     * 获取网络攻击表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:attack:query')")
    @GetMapping(value = "/{netId}")
    public AjaxResult getInfo(@PathVariable("netId") String netId)
    {
        return success(tbNetAttackService.selectTbNetAttackByNetId(netId));
    }

    /**
     * 新增网络攻击表
     */
    @PreAuthorize("@ss.hasPermi('system:attack:add')")
    @Log(title = "网络攻击表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbNetAttack tbNetAttack)
    {
        return toAjax(tbNetAttackService.insertTbNetAttack(tbNetAttack));
    }

    /**
     * 修改网络攻击表
     */
    @PreAuthorize("@ss.hasPermi('system:attack:edit')")
    @Log(title = "网络攻击表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbNetAttack tbNetAttack)
    {
        return toAjax(tbNetAttackService.updateTbNetAttack(tbNetAttack));
    }

    /**
     * 删除网络攻击表
     */
    @PreAuthorize("@ss.hasPermi('system:attack:remove')")
    @Log(title = "网络攻击表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{netIds}")
    public AjaxResult remove(@PathVariable String[] netIds)
    {
        return toAjax(tbNetAttackService.deleteTbNetAttackByNetIds(netIds));
    }
}
